<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <h1>双向绑定</h1>
        <input ref="nameTxt" type="text" v-on:keyup = "nameBind">
        <p>{{ name }}</p>

        <input type="text" v-model="age">
        <div>{{ age }}</div>
    </div>
    <script src="https://cdn.jsdelivr.net/npm/vue"></script>
    <script>
        new Vue({
            el:"#app",
            data:{
                name:"",
                age:""
            },
            methods:{
                nameBind: function(){
                    console.log(this.$refs.nameTxt.value);
                    this.name = this.$refs.nameTxt.value;

                }
            }
        })
    </script>
</body>
</html>